<?php 

abstract class singleton{
	/**
	 * Class instance.
	 */
	private static $instance; // class instance
   /**
    * Private constructor prevent direct instanciation of the object without using the singleton pattern. 
    */
   private function __construct(){}
   
	public abstract static function setClassName();
	
	/**
	 * return the instance and instanciate if it doesn't exists.
	 * @return Class
	 */
   public static function getInstance() {
      if (!isset(self::$instance)) {
         $c = self::setClassName();
         
		 echo "class=".__CLASS__;
         self::$instance = new $c;
      }
      return self::$instance;
   }
   public function __clone() {
		trigger_error('Cloning not autorized.', E_USER_ERROR);
   }
}
?>